
func void zs_mm_rtn_followtrf()
{
	B_ResetAll(self);
	perception_set_helper_rtn();
	self.aivar[AIV_StateTime] = 0;
};

func int zs_mm_rtn_followtrf_loop()
{
	var C_Item melee;
	var C_Item ranged;
	if(Npc_GetStateTime(self) >= (self.aivar[AIV_StateTime] + 1))
	{
		self.aivar[AIV_StateTime] = Npc_GetStateTime(self);
		if(HEROISTRANSFORMED == FALSE)
		{
			if(hero.guild > GIL_SEPERATOR_HUM)
			{
				HEROISTRANSFORMED = TRUE;
			}
			else if(self.aivar[AIV_StateTime] > 3)
			{
				return LOOP_END;
			};
		}
		else if(hero.guild < GIL_SEPERATOR_HUM)
		{
			if(Npc_HasEquippedMeleeWeapon(hero))
			{
				melee = Npc_GetEquippedMeleeWeapon(hero);
				if(Hlp_IsItem(melee,ItMw_Meisterdegen) || Hlp_IsItem(melee,ItMw_Addon_Betty))
				{
					B_AddFightSkill(hero,NPC_TALENT_2H,Waffenbonus_10);
				}
				else if(Hlp_IsItem(melee,ItMW_Addon_Stab01))
				{
					Npc_ChangeAttribute(hero,ATR_MANA_MAX,30);
					Npc_ChangeAttribute(hero,ATR_MANA,30);
				}
				else if(Hlp_IsItem(melee,ItMW_Addon_Stab02))
				{
					Npc_ChangeAttribute(hero,ATR_MANA_MAX,20);
					Npc_ChangeAttribute(hero,ATR_MANA,20);
				}
				else if(Hlp_IsItem(melee,ItMW_Addon_Stab03))
				{
					Npc_ChangeAttribute(hero,ATR_MANA_MAX,25);
					Npc_ChangeAttribute(hero,ATR_MANA,25);
				}
				else if(Hlp_IsItem(melee,ItMW_Addon_Stab03))
				{
					Npc_ChangeAttribute(hero,ATR_MANA_MAX,35);
					Npc_ChangeAttribute(hero,ATR_MANA,35);
				};
			};
			if(Npc_HasEquippedRangedWeapon(hero))
			{
				ranged = Npc_GetEquippedRangedWeapon(hero);
				if(Hlp_IsItem(ranged,ItRw_Addon_MagicBow) || Hlp_IsItem(ranged,ItRw_Addon_FireBow))
				{
					B_AddFightSkill(hero,NPC_TALENT_BOW,MAGICBOWBONUS);
				}
				else if(Hlp_IsItem(ranged,ItRw_Addon_MagicCrossbow))
				{
					B_AddFightSkill(hero,NPC_TALENT_CROSSBOW,MAGICCROSSBOWBONUS);
				};
			};
			b_applytransformedhp();
			HEROISTRANSFORMED = FALSE;
			return LOOP_END;
		};
		AI_Teleport(self,Npc_GetNearestWP(hero));
	};
	return LOOP_CONTINUE;
};

func void zs_mm_rtn_followtrf_end()
{
	HELPERBUGTRFCNT -= 1;
	self.flags = NPC_FLAG_GHOST;
	Npc_ChangeAttribute(self,ATR_HITPOINTS,-self.attribute[ATR_HITPOINTS_MAX]);
};

